package com.mallcloud.mall.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.mall.api.entity.XglCouponModel;
import com.mallcloud.mall.mall.mapper.XglCouponMapper;
import com.mallcloud.mall.mall.service.XglCouponService;
import org.springframework.stereotype.Service;

/**
 * 星光里券
 */
@Service
public class XglCouponServiceImpl extends ServiceImpl<XglCouponMapper, XglCouponModel> implements XglCouponService {

	/**
	 * 修改券图片
	 * @param dto
	 * @return
	 */
	@Override
	public Boolean updateXglCoupon(XglCouponModel dto) {
		long count = this.count(new LambdaQueryWrapper<XglCouponModel>()
				.eq(XglCouponModel::getScheduleId, dto.getScheduleId())
				.eq(XglCouponModel::getType, dto.getType())
		);
		if (count == 0) {
			return Boolean.TRUE;
		}
		return this.update(new LambdaUpdateWrapper<XglCouponModel>()
				.eq(XglCouponModel::getScheduleId, dto.getScheduleId())
				.eq(XglCouponModel::getType, dto.getType())
				.set(XglCouponModel::getImageBgUrl, dto.getImageBgUrl())
		);
	}
}
